package com.sfzlot.dev.netty.bean.identifier;

/**
 * Created by ASUS on 2017/5/27.
 * 数据加密方式
 */
public enum EncryptMethod {
    NO_ENCRYPTION(0x01), // 不加密
    RSA(0x02),           //RSA算法加密
    AES128(0x03),        //AES128位算法加密
    ERROR(0xFE),         //异常
    INVALIDE(0xFF);      //无效

    private int code;
    EncryptMethod(int code){
        this.code = code;
    }

    public int getCode() {
		return code;
	}

	/**
     * 根据code获取数据单元加密方式
     * @param code
     * @return
     */
    public static EncryptMethod getEncryptMethod(int code){
        for (EncryptMethod encryptMethod :
                EncryptMethod.values()) {
            if (encryptMethod.code == code) {
                return encryptMethod;
            }
        }
        throw new IllegalArgumentException();
    }
}
